package com.rule.front.api.drools;

import com.rule.drools.entity.EntityItemInfoEntity;
import com.rule.drools.service.EntityItemInfoService;
import com.rule.core.utils.PageUtils;
import com.rule.core.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 实体属性信息
 *
 * @author gz
 * @email 360568523@qq.com
 * @date 2019-05-25 14:54:38
 */
@RestController
@RequestMapping("rules/entityiteminfo")
public class EntityItemInfoController {
    @Autowired
    private EntityItemInfoService entityItemInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Result list(@RequestParam Map<String, Object> params){
        PageUtils page = entityItemInfoService.queryPage(params);

        return Result.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{itemId}")
    public Result info(@PathVariable("itemId") Long itemId){
		EntityItemInfoEntity entityItemInfo = entityItemInfoService.getById(itemId);

        return Result.ok().put("entityItemInfo", entityItemInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody EntityItemInfoEntity entityItemInfo){
		entityItemInfoService.save(entityItemInfo);

        return Result.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody EntityItemInfoEntity entityItemInfo){
		entityItemInfoService.updateById(entityItemInfo);

        return Result.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody Long[] itemIds){
		entityItemInfoService.removeByIds(Arrays.asList(itemIds));

        return Result.ok();
    }

}
